.class Lcom/htc/android/footprints/utils/FootprintUtils$1;
.super Ljava/lang/Thread;
.source "FootprintUtils.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/htc/android/footprints/utils/FootprintUtils;->exportKMZ(Landroid/app/Activity;Ljava/lang/String;[Lcom/htc/android/footprints/vo/Footprint;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = null
.end annotation


# instance fields
.field final synthetic val$activity:Landroid/app/Activity;

.field final synthetic val$additionName:Ljava/lang/String;

.field final synthetic val$dialog:Lcom/htc/android/footprints/commonui/ExportDialog;

.field final synthetic val$footprints:[Lcom/htc/android/footprints/vo/Footprint;


# direct methods
.method constructor <init>(Ljava/lang/String;Landroid/app/Activity;Lcom/htc/android/footprints/commonui/ExportDialog;[Lcom/htc/android/footprints/vo/Footprint;)V
    .locals 0
    .parameter
    .parameter
    .parameter
    .parameter

    .prologue
    .line 142
    iput-object p1, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$additionName:Ljava/lang/String;

    iput-object p2, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$activity:Landroid/app/Activity;

    iput-object p3, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$dialog:Lcom/htc/android/footprints/commonui/ExportDialog;

    iput-object p4, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$footprints:[Lcom/htc/android/footprints/vo/Footprint;

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 11

    .prologue
    const-string v10, "FootprintUtils"

    .line 145
    :try_start_0
    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v8, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$additionName:Ljava/lang/String;

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "_"

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    iget-object v8, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$activity:Landroid/app/Activity;

    invoke-virtual {v8}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v8

    invoke-static {v8}, Lcom/htc/android/footprints/utils/FootprintUtils;->getDateWithSerialNo(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 149
    .local v2, fileName:Ljava/lang/String;
    invoke-static {v2}, Lcom/htc/android/footprints/kml/KMLUtil;->getOuputFile(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 150
    .local v0, FILE_NAME:Ljava/lang/String;
    new-instance v5, Ljava/io/File;

    invoke-direct {v5, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 151
    .local v5, targetFile:Ljava/io/File;
    invoke-virtual {v5}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v7

    invoke-virtual {v7}, Ljava/io/File;->exists()Z

    move-result v7

    if-nez v7, :cond_0

    invoke-virtual {v5}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v7

    invoke-virtual {v7}, Ljava/io/File;->mkdir()Z

    .line 153
    :cond_0
    const-string v7, ".temp"

    const-string v8, ".kmz"

    invoke-virtual {v5}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v9

    invoke-static {v7, v8, v9}, Ljava/io/File;->createTempFile(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Ljava/io/File;

    move-result-object v6

    .line 155
    .local v6, tmpFile:Ljava/io/File;
    new-instance v3, Ljava/io/FileOutputStream;

    invoke-direct {v3, v6}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 157
    .local v3, fo:Ljava/io/FileOutputStream;
    iget-object v7, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$dialog:Lcom/htc/android/footprints/commonui/ExportDialog;

    invoke-static {v7}, Lcom/htc/android/footprints/kml/KMLUtil;->setProgressListener(Lcom/htc/android/footprints/kml/KMLUtil$OnProgressListener;)V

    .line 158
    iget-object v7, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$footprints:[Lcom/htc/android/footprints/vo/Footprint;

    invoke-static {v7, v3}, Lcom/htc/android/footprints/kml/KMLUtil;->exportKMZ([Lcom/htc/android/footprints/vo/Footprint;Ljava/io/OutputStream;)V

    .line 159
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->flush()V

    .line 160
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->close()V

    .line 163
    invoke-static {v6, v5}, Lcom/htc/android/footprints/utils/FootprintUtils;->copyFile(Ljava/io/File;Ljava/io/File;)Z

    move-result v4

    .line 165
    .local v4, isSuccess:Z
    invoke-virtual {v6}, Ljava/io/File;->delete()Z

    .line 168
    iget-object v7, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$dialog:Lcom/htc/android/footprints/commonui/ExportDialog;

    invoke-virtual {v7}, Lcom/htc/android/footprints/commonui/ExportDialog;->dismiss()V

    .line 170
    iget-object v7, p0, Lcom/htc/android/footprints/utils/FootprintUtils$1;->val$activity:Landroid/app/Activity;

    new-instance v8, Lcom/htc/android/footprints/utils/FootprintUtils$1$1;

    invoke-direct {v8, p0, v0}, Lcom/htc/android/footprints/utils/FootprintUtils$1$1;-><init>(Lcom/htc/android/footprints/utils/FootprintUtils$1;Ljava/lang/String;)V

    invoke-virtual {v7, v8}, Landroid/app/Activity;->runOnUiThread(Ljava/lang/Runnable;)V
    :try_end_0
    .catch Ljava/io/FileNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    .line 187
    .end local v0           #FILE_NAME:Ljava/lang/String;
    .end local v2           #fileName:Ljava/lang/String;
    .end local v3           #fo:Ljava/io/FileOutputStream;
    .end local v4           #isSuccess:Z
    .end local v5           #targetFile:Ljava/io/File;
    .end local v6           #tmpFile:Ljava/io/File;
    :goto_0
    return-void

    .line 182
    :catch_0
    move-exception v7

    move-object v1, v7

    .line 183
    .local v1, e:Ljava/io/FileNotFoundException;
    const-string v7, "FootprintUtils"

    invoke-virtual {v1}, Ljava/io/FileNotFoundException;->getMessage()Ljava/lang/String;

    move-result-object v7

    invoke-static {v10, v7, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0

    .line 184
    .end local v1           #e:Ljava/io/FileNotFoundException;
    :catch_1
    move-exception v7

    move-object v1, v7

    .line 185
    .local v1, e:Ljava/io/IOException;
    const-string v7, "FootprintUtils"

    invoke-virtual {v1}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v7

    invoke-static {v10, v7, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0
.end method
